package com.kingwood.algorithm.test;

import java.util.HashSet;
import java.util.Scanner;

/**
 * @Author 22025812
 * @Description: CPU算力分配
 * https://fcqian.blog.csdn.net/article/details/134746490
 * @Date: 2024/2/29 13:15
 * @Modified By：
 * @Version 1.0
 */
public class CPUSuanLiFenPei {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        while (scanner.hasNext()) {
            int l1 = scanner.nextInt();
            int l2 = scanner.nextInt();

            int sumA = 0;
            int[] A = new int[l1];
            for (int i = 0; i < l1; i++) {
                int a = scanner.nextInt();
                sumA += a;
                A[i] = a;
            }

            int sumB = 0;
            HashSet<Integer> setB = new HashSet<>();
            for (int i = 0; i < l2; i++) {
                int b = scanner.nextInt();
                sumB += b;
                setB.add(b);
            }

            int diff_half = (sumA - sumB) / 2;
            int minA = Integer.MAX_VALUE;
            String ans = "";

            for (int i = 0; i < l1; i++) {
                int a = A[i];
                int b = a - diff_half;
                if (setB.contains(b)) {
                    if (a < minA) {
                        minA = a;
                        ans = a + " " + b;
                    }
                }
            }

            System.out.println(ans);
        }
    }
}
